import sqlite3
import a_基金历史净值

from flask import Flask,render_template

app = Flask(__name__)


@app.route('/')
def index():  # put application's code here
    datalist = []
    con = sqlite3.connect("fundDB.db")
    cur = con.cursor()
    sql = "select * from Ranking"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()

    return render_template("index.html", funds =datalist)

@app.route('/gup')
def gup():
    datalist = []
    con = sqlite3.connect("fundDB.db")
    cur = con.cursor()
    sql = "select * from GuPiaoRanking"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()
    return render_template("gup.html", funds=datalist)

@app.route('/hun')
def hun():
    datalist = []
    con = sqlite3.connect("fundDB.db")
    cur = con.cursor()
    sql = "select * from HunHeRanking"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()

    return render_template("hun.html", funds=datalist)

@app.route('/zhishu')
def zhishu():
    datalist = []
    con = sqlite3.connect("fundDB.db")
    cur = con.cursor()
    sql = "select * from ZhiShuRanking"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()
    return render_template("zhishu.html", funds=datalist)

@app.route('/zj')
def zj():
    datalist = []
    con = sqlite3.connect("fundDB.db")
    cur = con.cursor()
    sql = "select * from ZhaiQuanRanking"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()

    return render_template("zj.html", funds=datalist)

@app.route('/log')
def log():
    return render_template("log.html")

@app.route('/team')
def team():
    return render_template("team.html")

@app.route('/idTable')
def idTable():
    datalist = []
    date = []  #日期
    num = []  # 日增长率
    con = sqlite3.connect("fundDB.db")
    cur1 = con.cursor()
    cur2= con.cursor()

    sql1 = "select * from 国泰大宗商品"
    sql2 = "select distinct FSRQ,DWJZ from  国泰大宗商品"

    data1 = cur1.execute(sql1)
    data2 = cur2.execute(sql2)
    for item in data1:
        datalist.append(item)

    for item in data2:
        date.append(item[0])
        num.append(item[1])
    cur1.close()
    cur2.close()
    con.close()

    return render_template("idTable.html",funds=datalist, date=date, num=num)

@app.route('/gong')
def gong():
    return render_template("gong.html")

@app.route('/index')
def index1():
    datalist = []
    con = sqlite3.connect("fundDB.db")
    cur = con.cursor()
    sql = "select * from Ranking"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()

    return render_template("index.html", funds=datalist)

@app.route('/com')
def com():

    return render_template("com.html")

@app.route('/tables')
def tables():
    return render_template("tables.html")


if __name__ == '__main__':
    app.run()
